<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://agi.corp.org/authz" prefix="authz"%>
<%@ page import="th.co.mfec.mca.common.PrivConst"%>

<script type="text/javascript" src="${requestScope.jsBase}/jQuery.dualListBox-1.0.1.min.js"></script>

<!-- body content -->
<!-- / body content -->
<div id="content">
<s:form id="mainForm" action="roleManagement-add.htm" method="post" >
	<s:hidden id="editMode" name="editMode" />
	
 	<s:if test="%{editMode == 'true'}">
 		<s:hidden name="userGroupBean.usgId" />
 	</s:if>

 <div class="tableContent">
 	<div id="dialoginfo"></div>
    <div class="topic">Add/Edit User Group</div>
    
    <div class="tableContent">
            <table>
            <colgroup class="L"></colgroup><colgroup class="R"></colgroup><colgroup class="L"></colgroup><colgroup class="R"></colgroup>
              <tr>
                 <th nowrap="nowrap"><s:text name="label.userGroupName" /><span class="star">*</span> : </th>
                 <td>
                 <s:textfield id="usgName" name="userGroupBean.usgName" maxlength="30" />
                	<br/><span id="errorsDiv_userGroupBean.usgName"></span>
                 </td>
              </tr>
              
              <tr>
                <th nowrap="nowrap"><s:text name="label.status" /><span class="star">*</span> :</th>
                <td><s:radio name="userGroupBean.usgStatus" list="statusList" listKey="value" listValue="label" /></td>
              </tr>
              
            </table>
   </div> 
 </div>
 <div class="button">
   		<table align="center">
            <tr>
              <td><authz:authorize granted="<%=PrivConst.S070201%>" ><span id="button"><a href="javascript:onClickSave();"><span><s:text name="button.save" /></span></a></span></authz:authorize></td>
              <td><span id="button"><a href="javascript:onClickBack();"><span><s:text name="button.back" /></span></a></span></td>
            </tr>
        </table>
   </div>
</s:form>
<br />
<br />
</div>

<script>
function onClickSave(){
	var form = document.forms['roleManagement-add'];
	var editMode = $j("#editMode").val();
	
    var rules=new Array();
    rules[0]='userGroupBean.usgName:User Group Name|required';
	rules[1]='userGroupBean.usgStatus:Status|required';

    if (yav.performCheck('mainForm', rules, 'inline')){
    	if(editMode == "true"){
			$j("#mainForm").attr("action","roleManagement-edit.htm"); 
		}
        
		$j("#mainForm").submit();
  		
	}else{
	}
	
}

function onClickBack(){
    $j("#mainForm").attr("action","roleManagement-search.htm"); 
  	$j("#mainForm").submit();
}

</script>
    